package br.com.lvc.bicho;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;

public class DialogUtils {


	public static void showDialogYesNo(int title, int message, Context context, DialogInterface.OnClickListener positiveEventAction, DialogInterface.OnClickListener negativeEventAction, int icon) {	
		showDialogYesNo(title, context.getString(message), R.string.yes, R.string.no, context, positiveEventAction, negativeEventAction, icon);
	}

	public static void showDialogYesNo(int title, String message, Context context, DialogInterface.OnClickListener positiveEventAction, DialogInterface.OnClickListener negativeEventAction, int icon) {	
		showDialogYesNo(title, message, R.string.yes, R.string.no, context, positiveEventAction, negativeEventAction, icon);
	}

	public static void showDialogYesNo(int title, String message,int labelButtonUm, int labelButtonDois, Context context, DialogInterface.OnClickListener positiveEventAction, DialogInterface.OnClickListener negativeEventAction, int icon) {
		showDialogTwoButton(title, message,labelButtonUm,  labelButtonDois,  context,  positiveEventAction,  negativeEventAction,  icon);
	}

	private static void showDialogTwoButton(int title, String message,int labelButtonUm, int labelButtonDois, Context context, final DialogInterface.OnClickListener positiveEventAction, final DialogInterface.OnClickListener negativeEventAction, int icon) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);		
		builder.setMessage(message);		
		builder.setPositiveButton(context.getString(labelButtonUm), positiveEventAction);
		builder.setNegativeButton(context.getString(labelButtonDois), negativeEventAction);
		AlertDialog dialog = builder.create();
		dialog.setTitle(title);
		dialog.setIcon(icon);
		
		dialog.setOnDismissListener(new OnDismissListener() {

			public void onDismiss(DialogInterface dialog) {
				dialog.dismiss();
				positiveEventAction.onClick(dialog, 0);
			}
		}); 
		
		dialog.show();
	}

	public static void showDialog(int icon, int title, int message, Context context,final DialogInterface.OnClickListener eventAction) {	
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setMessage(message);		
		builder.setPositiveButton("OK", eventAction);
		AlertDialog dialog = builder.create();		
		dialog.setTitle(title);
		dialog.setOnDismissListener(new OnDismissListener() {

			public void onDismiss(DialogInterface dialog) {
				dialog.dismiss();
				eventAction.onClick(dialog, 0);
			}
		});
		dialog.setIcon(icon);
		dialog.show();
	}


}
